$(function(){
    var pagebtn = $("#getMorePage");
    var item_ul = $(".common-item");
    pagebtn.click(function(a) {
        a && a.preventDefault();
        var nextpage = $(this).attr('page'),catalog = $(this).attr('param');
        $.ajax({type: "POST",url: "wap.php?code=getMore",data: {page:nextpage,catalog:catalog},dataType: "json",beforeSend: function() {
            pagebtn.addClass("non").html("加载中&hellip;")
        },success: function(b) {
            if (b.status === 1) {
            	
                var i=0;
                b.items.forEach(function(item) {
                    //if(b.type == "index") {
                	
                    var d = "<li><a href=\"wap.php?view=" + item.id  +"\"><div class=\"pic\"><img class=\"lazy\" src=\"/static/images/1x1.gif\" data-original=\"" + item.simg  +"\"  /></div>";
                    d = d+"<div class=\"item-name\"><div class=\"item-ico\">";
                    d = d+"<span class=\"icon-ticket\"></span></div>";
                    
                    d = d + "<h2>" + item.name + "</h2><h3>" + delHtmlTag(item.intro)+ "</h3>";
                    d = d + "<div class=\"item-edit\"><p class=\"price\"><b>¥" + item.nowprice + "</b><del>¥" + item.price + "</del></p><p class=\"num\">" + item.succ_buyers + "</p></div></div></a></li>";
                   
                        
                   // }
                    i++;
                    item_ul.append(d);
                });
                var n = b.items.length * (nextpage-1);
                $("img.lazy:gt("+n+")").lazyload({
                    effect : "fadeIn",
                    threshold : 200,
                    forceInit:false
                });
                nextpage = parseInt(nextpage) + 1;
                pagebtn.attr("page", nextpage);
                //nextpage <= b.pageCount ? pagebtn.removeClass('non').html('查看更多&hellip;') : pagebtn.addClass('non').html('全部显示完毕').unbind("click")
                pagebtn.removeClass('non').html('查看更多&hellip;')
            } else {
                pagebtn.addClass('non').html('全部显示完毕').unbind("click");
            }
        },error: function() {
        }})
    })
})

function delHtmlTag(str)
{
return str.replace(/<[^>]+>/g,"");//去掉所有的html标记
}
